package com.huya.mapper;

import com.github.pagehelper.Page;
import com.huya.pojo.dto.CasePageQueryDTO;
import com.huya.pojo.entity.Case;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CaseMapper {

    /**
     * 分页查询案件信息
     * @param casePageQueryDTO
     * @return
     */
    Page<Case> pageQuery(CasePageQueryDTO casePageQueryDTO);

    /**
     * 根据id列表删除案件信息
     * @param ids
     */
    void deleteByIds(List<Long> ids);

    /**
     * 根据id查询案件信息
     * @param id
     * @return
     */
    @Select("SELECT * FROM protection_cases WHERE id = #{id}")
    Case selectById(Long id);

    /**
     * 插入案件信息
     * @param caseInfo
     */
    @Insert("INSERT INTO protection_cases(title, case_type, occurrence_date, location, minors_involved, case_description, intervention_measures, outcome, prevention_tips, source, create_time) " +
            "VALUES" +
            "(#{title}, #{caseType}, #{occurrenceDate}, #{location}, #{minorsInvolved}, #{caseDescription}, #{interventionMeasures}, #{outcome}, #{preventionTips}, #{source}, #{createTime})  ")
    void insert(Case caseInfo);

    /**
     * 更新案件信息
     * @param caseInfo
     */
    void updateCase(Case caseInfo);
}
